package cc.ewell.esb.authenticating;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Application
{
    private Logger logger = LoggerFactory.getLogger(Application.class);
    private int ii = 0;
    String paramXml = Call.getParam(null);

    public static void main(String[] args) {
        Application app = new Application();


        app.testSinglePub();
    }

    public void testMuti() {
        int nThreads = Runtime.getRuntime().availableProcessors() + 1;
        ThreadPoolExecutor executor = new ThreadPoolExecutor(1500, 2000, 0L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
        for (int i = 0; i < 400; i++) {
            this.logger.debug("===>{}", Integer.valueOf(i));
            executor.execute(new Runnable() {
                int j = 0;
                Call call = new Call();

                public void run() {
                    while (true) {
                        String str = Call.callMethod("authenticateReqResp", Application.this.paramXml);

                        try {
                            Thread.sleep(1000L);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            });
        }
    }

    public String testSingle() {
        long startTime = System.currentTimeMillis();

        String str = Call.callMethod("authenticateReqResp", this.paramXml);
        this.logger.debug("总耗时  - {}ms", Long.valueOf(System.currentTimeMillis() - startTime));
        this.logger.debug("内容  - {}", str);
        return str;
    }

    public void testSinglePub() {
        Call call = new Call();
        String paramXml = null;
        paramXml = Call.getParam(paramXml);
        int i = 0;
        String str = Call.callMethod("authPubSub", paramXml);
        this.logger.debug("11.{} - {} - {}", new Object[] { Thread.currentThread(), str, Integer.valueOf(i++) });
    }
}

